import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

/// Opens an [AlertDialog] showing what the user typed.
class InputDemo extends StatefulWidget {
  InputDemo({Key key}) : super(key: key);

  @override
  _InputDemoState createState() => _InputDemoState();
}

/// State for [InputDemo] widgets.
class _InputDemoState extends State<InputDemo> {
  final TextEditingController _controller = TextEditingController();
  @override
  Widget build(BuildContext context) {
    var widget = Column(
//      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        TextField(
          controller: _controller,
          decoration: InputDecoration(
            hintText: 'Type something',
          ),
        ),
        RaisedButton(
          onPressed: () {
            showDialog(
              context: context,
              child: AlertDialog(
                title: Text('What you typed'),
                content: Text(_controller.text),
              ),
            );
          },
          child: Text('DONE'),
        ),
      ],
    );
    return Scaffold(appBar: AppBar(title: Text("输入demo")), body: widget);
  }
}
